package com.dji.compose_learning

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.Surface
import androidx.compose.runtime.getValue
import com.airbnb.lottie.compose.*

class LottieAnimationActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Surface {
                val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.polite_chicky))
                val progress by animateLottieCompositionAsState(composition = composition,
                    speed = 2f,
                    iterations = LottieConstants.IterateForever) //循环播放
                LottieAnimation(composition = composition, progress = progress)
            }
        }
    }
}